<template>

    <UserHeader />
    <div class="main">
        <div class="follow-user">
            <header>关注用户 <span>{{followList?.length}}个</span></header>
            <Loading v-show="!followList"></Loading>
            <main v-show="followList">
                <div 
                    v-for="item of followList"
                >
                    <img :src="item.avatarUrl">
                    <p>
                        <span>{{item.nickname}}</span>
                        <span>
                            <span>动态 {{item.eventCount}}</span>
                            <span>关注 {{item.follows}}</span>
                            <span>粉丝 {{item.followeds}}</span>
                        </span>
                        <span>{{item.signature}}</span>
                    </p>
                </div>
            </main>
        </div> 
    </div>
    <UserFooter />

</template>

<script setup>

    import { getCurrentInstance, onMounted, ref } from 'vue'
    const axios = getCurrentInstance().proxy.$http;
    let followList = ref();
    onMounted(async () => {
        const { data } = await axios.get('/login/status');
        let uid = data.data.profile.userId;
        try{
            if(!uid) return
            const { data } = await axios.get(`/user/follows?uid=${uid}`)
            if(data.code == 200) {
                followList.value = data.follow;
                console.log(followList.value);
            }
        }catch(err) {
            console.log(err);
        }
    })
    






</script>

<style lang="less" scoped>
    .follow-user{
        header{
            line-height: 30px;
            border-bottom: 3px solid #c20c0c;
            font-size: 20px;
            color: rgb(48, 47, 47);
            span{
                margin-left: 10px;
                font-size: 13px;
            }
        }
        main{
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 30px 50px;
            border: 1px solid #ccc;
            padding: 25px;
            div{
                height: 60px;
                // border: 1px solid black;
                display: grid;
                grid-template-columns: 60px 1fr;
                img{
                    width: 60px;
                    height: 100%;
                }
                p{
                    margin-left: 5px;
                    display: grid;
                    grid-template-rows: repeat(3, 1fr);
                    span{
                        display: block;
                        place-content: center;
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                        font-size: 12px;
                        &:nth-child(2) {
                            display: grid;
                            grid-template-columns: repeat(5, 1fr);
                            font-size: 10px;
                            place-content: center;
                        }
                        &:last-child{
                            font-size: 12px;
                        }
                    }
                }
            }
        }
    } 
</style>